package com.monitor.service.impl;

import com.monitor.dao.SmsShieldWordDao;
import com.monitor.po.SmsShieldWord;
import com.monitor.service.SmsShieldWordService;
import com.monitor.util.CommenUtil;
import com.monitor.util.Pager;

public class SmsShieldWordServiceImpl implements SmsShieldWordService {
	private SmsShieldWordDao smsShieldWordDao;

	@Override
	public Pager<SmsShieldWord> getSmsShieldWords(int currentPage, int pageSize) throws Exception {
		return smsShieldWordDao.getSmsShieldWords(currentPage, pageSize);
	}

	@Override
	public boolean addSmsShieldWord(String wordStr) throws Exception {
		if (CommenUtil.isEmpty(wordStr))
			return false;
		String[] words = wordStr.split(",");
		smsShieldWordDao.addSmsShieldWord(words);
		return true;
	}

	@Override
	public int deleteSmsShieldWord(String idStr) throws Exception {
		if (CommenUtil.isEmpty(idStr)) {
			return 0;
		}
		String[] idArray = idStr.split(",");
		int length = idArray.length;
		int[] ids = new int[length];
		for (int i = 0; i < length; i++) {
			ids[i] = Integer.parseInt(idArray[i]);
		}
		return smsShieldWordDao.deleteSmsShieldWord(ids);
	}

	public void setSmsShieldWordDao(SmsShieldWordDao smsShieldWordDao) {
		this.smsShieldWordDao = smsShieldWordDao;
	}

}
